package com.wut.easypoi.service.Impl;

import com.wut.easypoi.common.excel.MemberExcel;
import com.wut.easypoi.common.excel.OrderExcel;
import com.wut.easypoi.common.excel.ProductExcel;
import com.wut.easypoi.service.EasyPoiService;
import com.wut.utils.json.LocalJsonUtil;
import java.util.List;
import org.springframework.stereotype.Service;

@Service
public class EasyPoiServiceImpl implements EasyPoiService {

    @Override
    public List<OrderExcel> getOrderList() {
        List<OrderExcel> orderList = LocalJsonUtil.getListFromJson("json/orders.json", OrderExcel.class);
        List<ProductExcel> productList = LocalJsonUtil.getListFromJson("json/products.json", ProductExcel.class);
        List<MemberExcel> memberList = LocalJsonUtil.getListFromJson("json/members.json", MemberExcel.class);
        for (int i = 0; i < orderList.size(); i++) {
            OrderExcel order = orderList.get(i);
            order.setMember(memberList.get(i));
            order.setProductList(productList);
        }
        return orderList;
    }
}
